{{--@extends("base")--}}
@extends("admin.base")
@section("page")
    <style>
        @font-face {
            font-family: "";
        }
    </style>
    <div class="container-fluid p-4">
        <h1>电影类别添加页面000</h1>
        <div class="row">
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-body col-4">
{{--                        <form id="taypesform" action="insert" method="post">--}}
                        <form id="taypesform">
{{--                            @csrf--}}
                            <input type="hidden" name="id" value="{{isset($type)?$type->id:0}}">
                            <div class="col-6 p-1">
                                <label class="form-label" for="formrow-firstname-input">中文名称:</label>
                                <input type="text" name="name_ch" class="form-control" value="{{isset($type)?$type->name_ch:''}}">
                            </div>
                            <div class="col-md-6 p-1 ">
                                <div class="mb-3">
                                    <label class="form-label" for="formrow-email-input">维吾尔文名称:</label>
                                    <input type="text" name="name_uy" class="form-control" value="{{isset($type)?$type->name_uy:''}}" style="font-family: 'ALKATIP Gezit Tom'">
                                </div>
                            </div>
                            <div class="col-md-6 p-1">
                                <div class="mb-3">
                                    <label class="form-label" for="formrow-password-input">排序:</label>
                                    <input type="number" name="order" class="form-control" value="{{isset($type)?$type->order:''}}">
                                </div>
                            </div>
                        </form>
                        <div class="mt-3 mb-3 p-1">
                            <button onclick="submitTypes()" class="btn btn-primary w-md">提交</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
    </div>
@endsection

@section("scripts")
    <style>
        .swal-footer {
            text-align: center;
            padding-top: 13px;
            margin-top: 13px;
            padding: 13px 16px;
            border-radius: inherit;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }
    </style>
    <script>
        function submitTypes(){
            var data = $("#taypesform").serialize();
            console.log(data);
            console.log("nfeughbuyfhbutgdfhbvfevgjhebrcv");
            $.ajax({
                url:"http://dil.aynakedu.com/insert",  //请求的url地址
                dataType:"json",   //返回格式为json
                async:true,//请求是否异步，默认为异步，这也是ajax重要特性
                headers:{'X-CSRF-TOKEN':'{{csrf_token()}}' },
                data:data,    //参数值
                type:"POST",   //请求方式
                success:function(req){
                    if(req.err == 0){
                        swal({
                            title: "操作成功",
                            text: req.title,
                            icon: "success",
                            button: "知道了",
                        }).then((willDelete) => {
                            if (willDelete) {
                                location.href = "/types";
                            }
                        });
                    }
                },
                error:function(err){
                    //请求出错处理
                }
            });
        }
    </script>
@endsection


